package 面向对象;

import java.util.Random;

public class Role {
    private String name;
    private int age;
    private char gender;
    private String face;
    private int blood;

    String[] boyface = {"玉树临风","风流倜傥","气宇轩昂","温文尔雅 ","眉清目秀"};
    String[] girlface ={"美奂绝伦","沉鱼落雁","秀色难分","倾国倾城"};

    String[] attack_desc = {"%s使出一招【黑虎掏心】，手指好似铁石，直奔%s胸口去。",
            "%s使出一招【乌鸦坐飞机】，从天而降，直奔%s脑门去。",
            "%s使出一招【乌鸦坐飞机】，从天而降，直奔%s脑门去。",
            "%s使出一招【乌鸦坐飞机】，从天而降，直奔%s脑门去。",
            "%s大喝一声，运拳于胸前，一招【大力流星锤】，结结实实锤向%s。",
            "%s运气于丹田，使出一招【龟派气功】，漫天气机，冲向%s。"
    };
    String[] injureds_desc = {"结果%s一步不退，只是衣角微脏。",
            "结果%s退了几步，微微笑道，不过如此。",
            "结果%s痛苦的闷哼一声，显然受了点内伤。",
            "结果一击即中，打的%s口吐鲜血。",
            "结果%s轰然倒下，只剩进气声。"};

    public Role(){}
    public Role(String name ,int age ,char gender ,int blood ){
        this.name=name;
        this.age=age;
        this.gender=gender;
        this.blood =blood;
        setFace(gender);
    }
    public void setName(String name){
        this.name=name;
    }
    public String getName(){
        return name;
    }
    public void setAge(int age){
        this.age=age;
    }
    public int getAge(){
        return age;
    }
    public void setGender(char gender){
        this.gender=gender;
    }
    public char getGender(){
        return gender;
    }
    public void setFace(char gender){
        Random r  = new Random();
        if(gender == '男'){
           int index = r.nextInt(boyface.length);
           this.face=boyface[index];
        }else if(gender == '女'){
            int index = r.nextInt(girlface.length);
            this.face=girlface[index];
        }else{
            this.face="奇丑无比";
        }

    }
    public String getFace(){
        return face;
    }
    public void setBlood(int blood){
        this.blood=blood;
    }
    public int getBlood(){
        return blood;
    }
     public void attak(Role role){
        Random a = new Random();
        int index=a.nextInt(attack_desc.length);
        String KonFu = attack_desc[index];
        System.out.printf(KonFu,this.getName(),role.getName());

        //随机生产一个1-20的伤害值
         Random b = new Random();
         int hurt = b.nextInt(11)+40;
         //剩余血量
         int ShenXia = role.getBlood()-hurt;
         ShenXia = ShenXia <0 ? 0 :ShenXia;
         role.setBlood(ShenXia);

         if (ShenXia > 90){
             System.out.printf(injureds_desc[0],role.getName());
         }if (ShenXia > 80){
             System.out.printf(injureds_desc[1],role.getName());
         }if (ShenXia > 50){
             System.out.printf(injureds_desc[2],role.getName());
         }if (ShenXia > 20){
             System.out.printf(injureds_desc[3],role.getName());
         }else {
             System.out.printf(injureds_desc[4],role.getName());
         }

     }
     public void RoleInfo(){
        System.out.println("姓名："+getName());
         System.out.println("年龄："+getAge());
         System.out.println("性别："+getGender());
         System.out.println("血量："+getBlood());
         System.out.println("外貌："+getFace());
     }
}
